﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Model.HRWorkGrp
<!DOCTYPE html>

<html>
@Html.Partial("LoadPanelPartial")
<head>
    <title>GroupEdit</title>
        @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/PageCommon.js", true)" type="text/javascript"></script>
     <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>
         <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    <script>
        var i = 1;
        $(document).ready(function () {
            $("#toolMenu").smartFloat();
            var hdjsAlert = $("#hdjsAlert").val();
            if (hdjsAlert != "") {
                alert(hdjsAlert);
            }
            var hdMethod = $("#hdMethod").val();
            if (hdMethod == 'Edit') {
                var hdHRWorkGrpDutyList = $("#hdHRWorkGrpDutyList").val();
                if (hdHRWorkGrpDutyList != "") {
                    var model = JSON.parse(hdHRWorkGrpDutyList);
                    for (var z = 0; z < model.length; z++) {
                        var propname = "";
                        if (model[z].FDutyProp == "1") {
                            propname = "正级(主持工作)";
                        }
                        else if (model[z].FDutyProp == "2") {
                            propname = "副级";
                        }
                        else {
                            propname = "普通";
                        }
                        $("#position").append("<tr id='Edit" + z + "'><th align='center' width='10%'><a href='#' onclick=cpDelete('" + model[z].FWorkGrpNo + "','" + model[z].FWorkGrpDutyNo + "')>删除</a></th><th align='center'  width='30%'>" + model[z].FWorkGrpDutyNo + "</th><th class='td_text' width='30%'>" + model[z].FDutyName + "</th><th align='center' width='20%'>" + propname + "</th><th align='center' width='10%'>" + model[z].FSeq + "</th></tr>");
//                    <a href='#' onclick=cpEdit('" + model[z].FWorkGrpNo + "','" + model[z].FWorkGrpDutyNo + "')>修改</a>&nbsp;&nbsp;&nbsp;&nbsp;
                    }
                }

                var HRWorkGrpDutyNewList = $("#hdHRWorkGrpDutyNewList").val();
                if (HRWorkGrpDutyNewList != "") {
                    var model = JSON.parse(HRWorkGrpDutyNewList);
                    for (var z = 0; z < model.length; z++) {
                        var rowId = "tr" + i;
                     
                        if (model[z].FDutyProp == '1') {
                            $("#position").append("<tr id='" + rowId + "'><th align='center' width='10%'><a href='#' onclick=delRow('" + rowId + "')>删除</a></th><th align='center' width='30%'><input type='text' id='FWorkGrpDutyNo' name='FWorkGrpDutyNo' value='" + model[z].FWorkGrpDutyNo + "'></th><th align='center' width='30%'><input type='text' id='FDutyName' name='FDutyName' value='" + model[z].FDutyName + "'></th><th align='center' width='20%'><select id='FDutyProp' name='FDutyProp'><option value='1' select>正级(主持工作)</option><option value='2'>副级</option><option value='9'>普通</option></select></th><th align='center' width='10%'><input type='text' size='5' id='FSeq' name='FSeq' value='" + model[z].FSeq + "'></th></tr>");
                        }
                        else if (model[z].FDutyProp == '2') {
                            $("#position").append("<tr id='" + rowId + "'><th align='center' width='10%'><a href='#' onclick=delRow('" + rowId + "')>删除</a></th><th align='center' width='30%'><input type='text' id='FWorkGrpDutyNo' name='FWorkGrpDutyNo' value='" + model[z].FWorkGrpDutyNo + "'></th><th align='center' width='30%'><input type='text' id='FDutyName' name='FDutyName' value='" + model[z].FDutyName + "'></th><th align='center' width='20%'> <select id='FDutyProp' name='FDutyProp'><option value='1'>正级(主持工作)</option><option value='2' select>副级</option><option value='9'>普通</option></select></th><th align='center' width='10%'><input type='text' size='5' id='FSeq' name='FSeq' value='" + model[z].FSeq + "'></th></tr>");
                        }
                        else {
                            $("#position").append("<tr id='" + rowId + "'><th align='center' width='10%'><a href='#' onclick=delRow('" + rowId + "')>删除</a></th><th align='center' width='30%'><input type='text' id='FWorkGrpDutyNo' name='FWorkGrpDutyNo' value='" + model[z].FWorkGrpDutyNo + "'></th><th align='center' width='30%'><input type='text' id='FDutyName' name='FDutyName' value='" + model[z].FDutyName + "'></th><th align='center' width='20%'><select id='FDutyProp' name='FDutyProp'><option value='1'>正级(主持工作)</option><option value='2'>副级</option><option value='9' select >普通</option></select></th><th align='center' width='10%'><input type='text' size='5' id='FSeq' name='FSeq' value='" + model[z].FSeq + "'></th></tr>");
                        }
                        i++;
                    }
                }
            }

            else {
                var hdHRWorkGrpDutyList = $("#hdHRWorkGrpDutyNewList").val();
                if (hdHRWorkGrpDutyList != "") {
                    var model = JSON.parse(hdHRWorkGrpDutyList);
                    for (var z = 0; z < model.length; z++) {
                        var rowId = "tr" + i;
                        if (model[z].FDutyProp == '1') {
                            $("#position").append("<tr id='" + rowId + "'><th align='center' width='10%'><a href='#' onclick=delRow('" + rowId + "')>删除</a></th><th align='center' width='30%'><input type='text' id='FWorkGrpDutyNo' name='FWorkGrpDutyNo' value='" + model[z].FWorkGrpDutyNo + "'></th><th align='center' width='30%'><input type='text' id='FDutyName' name='FDutyName' value='" + model[z].FDutyName + "'></th><th align='center' width='20%'><select id='FDutyProp' name='FDutyProp'><option value='1' select>正级(主持工作)</option><option value='2'>副级</option><option value='9'>普通</option></select></th><th align='center' width='10%'><input type='text' size='5' id='FSeq' name='FSeq' value='" + model[z].FSeq + "'></th></tr>");
                        }
                        else if (model[z].FDutyProp == '2') {
                            $("#position").append("<tr id='" + rowId + "'><th align='center' width='10%'><a href='#' onclick=delRow('" + rowId + "')>删除</a></th><th align='center' width='30%'><input type='text' id='FWorkGrpDutyNo' name='FWorkGrpDutyNo' value='" + model[z].FWorkGrpDutyNo + "'></th><th align='center' width='30%'><input type='text' id='FDutyName' name='FDutyName' value='" + model[z].FDutyName + "'></th><th align='center' width='20%'> <select id='FDutyProp' name='FDutyProp'><option value='1'>正级(主持工作)</option><option value='2' select>副级</option><option value='9'>普通</option></select></th><th align='center' width='10%'><input type='text' size='5' id='FSeq' name='FSeq' value='" + model[z].FSeq + "'></th></tr>");
                        }
                        else {
                            $("#position").append("<tr id='" + rowId + "'><th align='center' width='10%'><a href='#' onclick=delRow('" + rowId + "')>删除</a></th><th align='center' width='30%'><input type='text' id='FWorkGrpDutyNo' name='FWorkGrpDutyNo' value='" + model[z].FWorkGrpDutyNo + "'></th><th align='center' width='30%'><input type='text' id='FDutyName' name='FDutyName' value='" + model[z].FDutyName + "'></th><th align='center' width='20%'><select id='FDutyProp' name='FDutyProp'><option value='1'>正级(主持工作)</option><option value='2'>副级</option><option value='9' select >普通</option></select></th><th align='center' width='10%'><input type='text' size='5' id='FSeq' name='FSeq' value='" + model[z].FSeq + "'></th></tr>");
                        }
                        i++;
                    }
                }
            }

        });
        function addRow() {
            var rowId = "tr" + i;
            $("#position").append("<tr id='" + rowId + "'><th align='center' width='10%'><a href='#' onclick=delRow('" + rowId + "')>删除</a></th><th align='center' width='30%'><input type='text' id='FWorkGrpDutyNo' name='FWorkGrpDutyNo'></th><th align='center' width='30%'><input type='text' id='FDutyName' name='FDutyName'></th><th align='center' width='20%'><select id='FDutyProp' name='FDutyProp'><option value='1'>正级(主持工作)</option><option value='2'>副级</option><option value='9'>普通</option></select></th><th align='center' width='10%'><input type='text' size='5' id='FSeq' name='FSeq' value='" + i + "'></th></tr>");
            i++;
        }
        function delRow(rowId) {
            $("#" + rowId).remove();
        }

        function cpDelete(FWorkGrpNo, FWorkGrpDutyNo) {
            if (confirm("确定删除")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/Group/DelDuty',
                    data: { FWorkGrpNo: FWorkGrpNo, FWorkGrpDutyNo: FWorkGrpDutyNo },
                    success: function (result) {
                        if (result == "ok") {
                            alert("删除成功!");
                            window.location.reload(); 
                        } else if (result == "error") {
                            alert("删除失败!");
                        } else {
                            alert("删除参数错误!");
                        }
                    }
                });
            }
        }

        function save() {
            var isCtlAllValid = true;
            var errorText = "";
            ASPxClientEdit.ValidateEditorsInContainer(null);
            
            var clientFLogIDObj = ASPxClientTextBox.Cast("FWorkGrpNo");
            if (!clientFLogIDObj.GetIsValid()) {
                isCtlAllValid = false;
                errorText += clientFLogIDObj.GetErrorText() + "\n";

            }
            var clientFUserNameObj = ASPxClientTextBox.Cast("FWorkGrpName");
            if (!clientFUserNameObj.GetIsValid()) {
                isCtlAllValid = false;
                errorText += clientFUserNameObj.GetErrorText() + "\n";

            }


            if (isCtlAllValid) {
                form1.submit();
            }
            else {
                alert(errorText);
            }
        }

        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnSave":
                    {
                        //保存
                        save();
                        break;
                    }
                case "btnCancel":
                    {
                        //密码重置
                        window.location.href = rootPath + "/Admin/Group/GroupList";
                        break;
                    }
            }
        }
    </script>
    
    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)
</head>
<body>
@using (Html.BeginForm("SaveGroup", "Group", FormMethod.Post, new { id = "form1" }))
{ 
        <div class="floatToolMenu" id="toolMenu">
            @Html.DevExpress().Menu(settings =>
      {
          settings.Name = "toolBarMenu";
          settings.ItemAutoWidth = false;
          settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
          settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
          settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

          settings.Items.Add(item =>
          {
              item.Name = "btnSave";
              item.Text = "保存";
              item.ClientEnabled = true;
              item.Image.Url = Url.Content("~/Content/ControlImages/filesave.png");

          });
          settings.Items.Add(item =>
          {
              item.Name = "btnCancel";
              item.Text = "取消";
              item.ClientEnabled = true;
              item.Image.Url = Url.Content("~/Content/ControlImages/no.png");

          });
          settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
          settings.ItemLinkMode = ItemLinkMode.ContentBounds;
      }).GetHtml()
        </div>
    <div class="div">
        <table width="100%" align="center" class="tableForm">
            <tr>
                <th colspan="4" style="font-weight:bolder; font-size:larger; text-align:center">
                @Html.DevExpress().Label(settings => { settings.Text = "工作组基本信息";
           settings.ControlStyle.Font.Bold = true;                                                                          
                 }).GetHtml()<br /><br /></th>
            </tr>
            <tr>
                <th width="15%" style =" text-align:right">@Html.DevExpress().Label(settings => { settings.Text = "工作组编号:"; }).GetHtml() </th>
                <th width="35%" style =" text-align:left"> @Html.DevExpress().TextBox(settings =>
          {
              settings.Name = "FWorkGrpNo";
              settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
              settings.Text = Model.FWorkGrpNo;
              settings.Enabled = (bool)ViewData["blemp"];
              settings.Properties.ClientSideEvents.Validation = "function(s,e){notEmptyValidation(s,e,'工作组编号')}";
          }).GetHtml()</th>
                <th width="15%" style =" text-align:right">@Html.DevExpress().Label(settings => { settings.Text = "工作组名称:"; }).GetHtml()</th>
                <th width="35%" style =" text-align:left">@Html.DevExpress().TextBox(settings =>
          {
              settings.Name = "FWorkGrpName";
              settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
              settings.Text = Model.FWorkGrpName;
              settings.Properties.ClientSideEvents.Validation = "function(s,e){notEmptyValidation(s,e,'工作组名称')}";
          }).GetHtml()</th>
            </tr>
            <tr>
                <th style =" text-align:right">@Html.DevExpress().Label(settings => { settings.Text = "是否启用:"; }).GetHtml()</th>
                <th style =" text-align:left" colspan="3">
 @Html.DevExpress().RadioButtonList(settings =>
       {
           settings.Name = "FIsUse";
           settings.Properties.RepeatLayout = System.Web.UI.WebControls.RepeatLayout.Table;
           settings.Properties.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
           settings.Properties.RepeatColumns = 2;
       }).BindList(new List<SelectListItem> { new SelectListItem { Text = "是", Value = "Y" }, new SelectListItem { Text = "否", Value = "N" } }).Bind(Model.FIsUse).GetHtml()
                </th>
            </tr>
        </table>
    </div>
    <br />
    <div class="div">
        <fieldset style="width:100%;" align="center">
            <legend>@Html.DevExpress().Label(settings => { settings.Text = "工作组职务"; }).GetHtml()</legend>
                <table width="99%" align="center" class= "tableForm" id="position">
                    <tr>
                        <th width="10%" class="td_text" style =" text-align:center">@Html.DevExpress().Label(settings => { settings.Text = "操作"; }).GetHtml()</th>
                        <th width="30%" class="td_text" style =" text-align:center">@Html.DevExpress().Label(settings => { settings.Text = "职务编号"; }).GetHtml()</th>
                        <th width="30%" class="td_text" style =" text-align:center">@Html.DevExpress().Label(settings => { settings.Text = "职务名称"; }).GetHtml()</th>
                        <th width="20%" class="td_text" style =" text-align:center">@Html.DevExpress().Label(settings => { settings.Text = "职务性质"; }).GetHtml()</th>
                        <th width="10%" class="td_text" style =" text-align:center">@Html.DevExpress().Label(settings => { settings.Text = "显示顺序"; }).GetHtml()</th>
                    </tr>
                </table>
                <div style="text-align:center"><input type="button" value="增加工作组职务" onclick="addRow()" /></div>
        </fieldset>
    </div>
        @Html.Hidden("hdMethod", ViewData["hdMethod"]);
        @Html.Hidden("hdjsAlert", (ViewData["jsAlert"]));
        @Html.Hidden("hdHRWorkGrpDutyList", (ViewData["HRWorkGrpDutyList"]));
        @Html.Hidden("hdHRWorkGrpDutyNewList", (ViewData["HRWorkGrpDutyNewList"]));
}
        <script type="text/javascript" language="javascript">
            lp.Hide();
    </script>
</body>
</html>
